{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>发布消息</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="add_article" id="add_article" enctype="multipart/form-data">
                        <input type="hidden" name="id" value="{$res['welfare_id']}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label cyanse" for="myEditor">详情：</label>
                            <div class="input-group col-sm-9">
                                <textarea name="detail"  style="width:90%" id="myEditor"><?php echo(html_entity_decode($res['welfare_content']?$res['welfare_content']:''))?></textarea>
                            </div>
                        </div>

                        <div class="form-group" id="user_list">
                            <label class="col-sm-3 control-label">选择用户：</label>
                            <div class="input-group col-sm-4">
                                <select name="user_id[]"  id="n_user_id" xm-select="select1" lay-verify="required" xm-select-search="">
                                    {volist name="list" id="vo"}
                                    <option value="{$vo.user_id}" {if in_array($vo['user_id'],$res['user_list'])} selected="selected" {/if}>{$vo.user_username}({$vo.mechanism_name})</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="input-group col-sm-4">
                                <input id="title"  value="{$res['welfare_title']?$res['welfare_title']:''}" type="text" class="form-control" name="title" placeholder="输入标题">
                            </div>
                        </div>






                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary btsave"  type="button"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">
    //百度富文本编辑器
    var editor = UE.getEditor('myEditor', {
        initialFrameHeight:450,
        autoHeight: false,
        autoHeightEnabled:false,
        autoFloatEnabled:false
    });
</script>
<script>

    $(".btsave").on('click',function () {
        var title = $.trim($("#title").val());
        if(title<1){
            layer.msg("信息标题不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            return false;
        }

        $.ajax({
            url: "{:url('update')}",
            type: "post",
            dataType: "json",

            data: $("#add_article").serialize(),
            success: function (data) {
                if (data.code == 200) {
                    wk.success(data.msg,1,"{:url('welfare/index')}");
                } else if(data.code == 100){
                    $('.btn').removeAttr('disabled');
                    wk.error(data.msg,2,'');
                    return false;
                }
            }
        });
    })
</script>
</body>

</html>